package com.emperor.controller.orderservice;

import com.emperor.result.Result;
import com.emperor.service.ReportService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.time.LocalDateTime;

@RestController
@RequestMapping("/order-service/report")
@Api(tags = "首页")
public class ReportController {
    @Autowired
    private ReportService reportService;

    @GetMapping("/orderCount")
    @ApiOperation("当月订单总量")
    public Result orderCount(@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") LocalDateTime start, @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") LocalDateTime end) {
        Integer order = reportService.orderCount(start, end);
        return Result.success(order);
    }

    @GetMapping("/orderAmount")
    @ApiOperation("当月订单总额")
    public Result orderAmount(@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") LocalDateTime start, @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") LocalDateTime end) {
        Integer order = reportService.orderAmount(start, end);
        return Result.success(order);
    }
}
